<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:gmr="http://CygNetSCADA.com/Schemas/CygNetGMRExport" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
extension-element-prefixes="date"
exclude-result-prefixes="#all">

<xsl:import href="date.add.template.xsl" />

<xsl:param name="tgtSystemType" />
<xsl:param name="srcSystemType" />


<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/gmr:CygNetGMRExport">
		<message>
			<header>
				<action>locationquantity</action>
				<version>1.0</version>
				<sourceSystem>CYGNET_SCADA</sourceSystem>
				<originatingSystem>GMR</originatingSystem>
			</header>
			<body>
				<locationId>
					 <xsl:value-of select="@meterid"/>
				</locationId>
				<commodity>GAS</commodity>
				<locationQuantity quantityType="MEASURED" qtyClassification="MEASUREMENT">
						<xsl:apply-templates select="//gmr:Values"/>
			    </locationQuantity>
			</body>
		</message>
	</xsl:template>
	
	
	<xsl:template match="//gmr:Values">
		<locationQuantityDetail>
			<begDate><xsl:value-of select="format-dateTime(@devicestarttime, '[Y]-[M01]-[D01]T[H01]:[m01]:[s01]')"/></begDate>
			<endDate> 
				<xsl:call-template name="date:add">
				   <xsl:with-param name="date-time" select="xs:dateTime(@devicestarttime)" />
				   <xsl:with-param name="duration">PT1H</xsl:with-param>
				</xsl:call-template>
			</endDate>
			<quantityStatus>ACTUAL</quantityStatus>
			<volumeQuantity><xsl:value-of select="gmr:FLOW_VOLUME"/></volumeQuantity>
			<volumeUnitOfMeasure>MCF</volumeUnitOfMeasure>
			<!--
			<energyUnitOfMeasure>DTH</energyUnitOfMeasure>
			-->
			<frequency>HOURLY</frequency>
			<flowDirection>REC</flowDirection>
		</locationQuantityDetail>
	</xsl:template>	
	
</xsl:stylesheet>

